//
//  CustomMenuBt.m
//  ChunLaiZhuangClient
//
//  Created by zouzhisheng on 16/3/6.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "CustomMenuBt.h"

@implementation CustomMenuBt

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame norImage:(NSString*)norImage selectedImage:(NSString*)selectedImage titile:(NSString*)title;
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 1、顶部图片
        self.imageView.contentMode = UIViewContentModeCenter;
        [self setImage:[UIImage imageNamed:norImage] forState:UIControlStateNormal];
        [self setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateSelected];
        
        // 2、设置文字
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:titleColor forState:UIControlStateNormal];
        [self setTitleColor:selectedTitleColor forState:UIControlStateSelected];
        self.titleLabel.font=titleFont;
        
    }
    return self;
}
#pragma mark - 设置按钮内部图片和文字的frame
- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat W = contentRect.size.width;
    CGFloat H = contentRect.size.height *ImageScale;
    return CGRectMake(0, 22-H/2, W, H);
}
- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat W = contentRect.size.width;
    CGFloat H = contentRect.size.height *ImageScale;
    CGFloat y = contentRect.size.height - H;
    return CGRectMake(25, 22-H/2, W, H);}

@end
